home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / DCLAP 4j / DApp / SeqPup.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-17  |  18.1 KB  |  708 lines  |  [TEXT/R*ch]

  1. // SeqPup.cp
  2. // d.g.gilbert -- biosequence editor & analysis platform
  3. // Jan 1994
  4.  
  5. #define UseGopher  0
  6.  
  7. #include <DClap.h>
  8. #if UseGopher
  9. #  include <DNet.h>
  10. #else
  11. #  include <DTCP.h>
  12. #  include <DSMTPclient.h>
  13. #  include <DSendMailDialog.h>
  14. #endif
  15. #include <DBio.h>
  16. #include <DRich.h>
  17. #include <DDrawPICT.h>
  18. #include <DSeqPict.h>
  19. #include <Dversion.h>
  20.  
  21. void AboutSeqPupPicture(); // DAboutSeqPup.cpp
  22.  
  23.  
  24.  
  25. class DSeqPup : public DApplication
  26. {
  27. public:
  28.     static char* kBugmailAddress;
  29.     static char* kGopherRTFDocSuffix;
  30.     
  31.     enum appMenus { kInternetMenu = 100, kPrefsMenu, kOpenMenu };  
  32.     enum menuCmds { 
  33.         kSeqPrefs=1001,  kOtherPrefs, kEditGopherMap,
  34.         kViewByDefault,kViewByDate,kViewBySize,kViewByName,kViewByKind,kViewByHost,
  35.         kViewAsText, kViewAsLink,
  36.         kOpenDoc, kFetchLink, kFetchDefault, // kFetchView1...kFetchViewN
  37.         kFetchOptionFlag, kAutoloadFlag,
  38.         kViewPrefs, kCodonPref,kREnzymePref,kColorPref,kStylePref,
  39.         kSaveWinPrefs,kSeqPrintPrefs, kSeqDocPrefs,
  40.         kGetInfo, kMailAdmin, kOpenLocalGo,
  41.         kNewServer,kFindServer,kNewLink, kEditLink,kExtractGodoc,kLockWindow,
  42.         kOpenText, kOpenSeq, kOpenAppendSeq, kOpenTree,  
  43.         kMailSetup, kSendMail, kBugMail
  44.         };
  45.  
  46.     DView *    fFetchOptionMenuItem;
  47.     DView *    fLockWinMenuItem;
  48.     DView * fAutoloadItem;
  49.     DMenu * fViewsMenu;
  50.     Boolean fWinPrefsNotSaved, fAppendSeq;
  51.     
  52.     void ISeqPup();     
  53.     virtual ~DSeqPup();
  54.     void DoAboutBox();
  55.  
  56.     virtual void SetUpMenus();    
  57.     virtual    Boolean IsMyAction(DTaskMaster* action);
  58.     virtual Boolean IsInternetMenu(DTaskMaster* action); 
  59.     virtual    void UpdateMenus(); 
  60.     virtual void OpenDocument(DFile* aFile);
  61.     virtual void OpenLocalGopher();
  62.     DWindow* DoMakeDocument(short itsCommandNumber, DFile* aFile);
  63. };
  64.  
  65.  
  66. char* DSeqPup::kBugmailAddress= "seqpup@bio.indiana.edu";
  67. char* DSeqPup::kGopherRTFDocSuffix = ".start";
  68.  
  69.  
  70.     // here we go -- the Nlm_Main() program (called from main() in ncbimain.c)
  71. extern "C" short Main(void)
  72. {
  73.   DSeqPup* app = new DSeqPup();
  74.   app->ISeqPup();
  75.   app->Run();
  76.   delete app; 
  77.   return 0;
  78. }
  79.  
  80.  
  81.  
  82. void DSeqPup::ISeqPup()
  83. {
  84.     DApplication::kName= "SeqPup";
  85.     DApplication::kVersion= (char*) kDCLAPVersionString; //" v 0.4";
  86.     
  87.     fFetchOptionMenuItem= NULL;
  88.     fLockWinMenuItem= NULL;
  89.     fWinPrefsNotSaved= true;
  90.     fAppendSeq= false;
  91.     fAutoloadItem = NULL;
  92. #if UseGopher
  93.     gGopherDoc = NULL; // ??? this should be set, but isn't in 68K ??
  94. #endif
  95.     fViewsMenu= NULL;
  96.     fFileSuffix = NULL; // unix, msdos file suffix
  97.     fAcceptableFileTypes = NULL;     // really want "IGo4 BKMK TEXT" and perhaps others
  98.                                                                 // but NCBI tools only handle 1 type now
  99.     IApplication();
  100.     
  101. #if UseGopher
  102.         // network doc initializations
  103.     InitializeUGopher();
  104.     DGoviewPrefs::InitGlobals();
  105.     DGoOtherPrefs::InitGlobals();
  106.     if (fFetchOptionMenuItem) fFetchOptionMenuItem->SetStatus(DGopherListDoc::gOptionIsOn);
  107.     if (fAutoloadItem) fAutoloadItem->SetStatus(DGoLinkedTextDoc::gAutoloadInlines);
  108. #endif
  109.  
  110.     DRichView::InitRichView();
  111.     
  112.         // sequence initializations
  113.     DSeqDoc::GetGlobals(); //SeqDocPrefs(kSeqDocPrefInit);
  114.     DCodons::Initialize("codon","data","tables:codon.table");
  115.     DREMap::Initialize("renzyme","data","tables:renzyme.table");
  116.     DBaseColors::Initialize("color","data","tables:color.table");
  117.     if (DBaseColors::NotAvailable()) ; // read in DBaseColors data now 
  118.     DStyleTable::Initialize("seqmasks","data","tables:seqmasks.table");
  119.     if (DStyleTable::NotAvailable()) ; // read in DStyleTable data now 
  120.     
  121.         // default documents ??
  122.     if (DSeqDoc::fgStartDoc) DSeqDoc::NewSeqDoc();
  123.     {
  124.         // open default gopher document if it exists.
  125.         // TRY RTF Form first (.start ?? )
  126.         // open both default.go4 and default.start files, if they exist !
  127.     char godefault[512];
  128. #if UseGopher
  129.     StrNCpy(godefault, (char*)Shortname(), 512);    
  130.     StrNCat(godefault, DGopherListDoc::kGopherDocSuffix, 512);
  131.     DApplication::OpenDocument( (char*)godefault);
  132. #endif
  133.     StrNCpy(godefault, (char*)Shortname(), 512);    
  134.     StrNCat(godefault, kGopherRTFDocSuffix, 512);
  135.     DApplication::OpenDocument( (char*)godefault);
  136.     }
  137.  
  138. }     
  139.  
  140.  
  141. DSeqPup::~DSeqPup()
  142. {
  143. #if UseGopher
  144.     DGoviewPrefs::SaveGlobals();
  145.     DGoOtherPrefs::SaveGlobals();
  146. #endif
  147.     if (fWinPrefsNotSaved) DSeqDoc::SaveGlobals(); 
  148.     DDrawPict::Cleanup();
  149. }
  150.  
  151.  
  152. void DSeqPup::DoAboutBox()
  153. {
  154. #if !defined(WIN_MSWIN) && !defined(WIN_MOTIF)
  155.         // problems yet w/ this large codepic in mswin(WIN16) and unix/motif
  156.     AboutSeqPupPicture();
  157. #else
  158.     char aboutMe[512];
  159.     sprintf( aboutMe, "SeqPup, version %s"LINEEND
  160.                 " a biosequence editor & analysis application "LINEEND
  161.                 " copyright by D.G. Gilbert, 1990-1995"
  162.                 , DApplication::kVersion);
  163.     DAboutBoxWindow* about = new DAboutBoxWindow(aboutMe);
  164. #endif
  165. }
  166.  
  167.  
  168. void DSeqPup::SetUpMenus(void)
  169. {
  170.     //DApplication::SetUpMenus();
  171.  
  172.     DMenu* aMenu = NULL;
  173. #ifdef WIN_MAC
  174.     DAppleMenu* appleMenu = new DAppleMenu(this,fAboutLine);
  175. #endif
  176.     if (!aMenu) aMenu = this->NewMenu( cFileMenu, "File");
  177. #ifndef WIN_MAC
  178.     aMenu->AddItem(kAbout, fAboutLine);
  179.     aMenu->AddSeparator();
  180. #endif
  181.     aMenu->AddItem(kNew,"New/N", false, true);
  182.  
  183.     aMenu->AddItem( kOpenSeq, "Open sequence.../O",false, true);
  184.     //aMenu->AddItem(kOpen,"Open.../O",false, true);
  185.     DMenu* oMenu= new DSubMenu( kOpenMenu, aMenu, "Open other");
  186.     //oMenu->AddItem( kOpenSeq, "Sequence file.../O",false, true);
  187.     oMenu->AddItem( kOpenText, "Text,RTF,Image...",false, true);
  188.     oMenu->AddItem( kOpenAppendSeq, "Append sequence...",false, true);
  189.     //oMenu->AddItem( kOpenTree, "Phylogenetic tree...",false, true);
  190.     //oMenu->AddItem( kOpenLocalGo,"Open Local gopher...",false, true);
  191.     //oMenu->AddItem( kNewServer,"Open Remote.../R",false, true);
  192.  
  193.     aMenu->AddSeparator();
  194.     aMenu->AddItem(kClose,"Close/W",false, true);
  195.     aMenu->AddItem(kSave,"Save/S",false, true);
  196.     aMenu->AddItem(kSaveAs,"Save As...",false, true);
  197.     aMenu->AddItem(DSeqDoc::cSaveSel,"Save selection...",false, true);
  198.     aMenu->AddSeparator();
  199.     aMenu->AddItem(kPrint,"Print",false, true);
  200.     aMenu->AddItem(kHelp,"Help/H",false, true);
  201.     aMenu->AddSeparator();
  202.     aMenu->AddItem(kQuit,"Quit/Q",false, true);
  203.  
  204.     aMenu= NULL;
  205.     this->SetUpMenu(DApplication::cEditMenu, aMenu);
  206.     DSeqDoc::SetUpMenu(DApplication::cEditMenu, aMenu);
  207.  
  208.     DMenu* sMenu = NULL;
  209.     DSeqDoc::SetUpMenu(DSeqDoc::kSeqMenu, sMenu);
  210.  
  211.     DMenu* iMenu = NewMenu( kInternetMenu, "Internet");
  212.     //iMenu->AddItem( kMailSetup, "Mail setup...");
  213.      //iMenu->AddSeparator();        
  214.  
  215.     DSeqDoc::SetUpMenu(DSeqDoc::kInternetMenu, iMenu);
  216.      
  217.     iMenu->AddItem( kSendMail, "Send Mail...");
  218.     iMenu->AddItem( kBugMail, "Comment on this app...");
  219.  
  220.     DMenu* cMenu = NULL;
  221.     DSeqApps::SetUpMenu(DSeqApps::kChildMenu, cMenu);
  222.     
  223.     iMenu = NewMenu( kPrefsMenu, "Options");
  224.     iMenu->AddItem( kSeqDocPrefs, "Seq Prefs...",false, true);
  225.     iMenu->AddItem( kSeqPrintPrefs, "SeqPrint Prefs...", false, true); 
  226.     iMenu->AddItem( kColorPref, "Base color table...", false, true);
  227.     iMenu->AddItem( kStylePref, "Base style table...", false, true);
  228.     iMenu->AddItem( kCodonPref, "Codon table...", false, true);
  229.     iMenu->AddItem( kREnzymePref, "R.Enzyme table...", false, true);
  230.     iMenu->AddItem( kSaveWinPrefs, "Save window settings", false, true);
  231.     // add opt to save current aln window size,text-lock,color-state to prefs ?
  232.     // or do automatically on close?
  233.     iMenu->AddSeparator();
  234.     
  235. #if UseGopher
  236.     iMenu->AddItem( kViewPrefs, "View Prefs...", false, true); 
  237. #if NETSTUF_LATER
  238.     iMenu->AddItem( kFetchOptionFlag, "Fetch with options", true, true);
  239.         // we can only access menu item thru gViewCentral now the way DMenu::AddItem() is written...
  240.     fFetchOptionMenuItem= (DView*) gViewCentral->GetView(kFetchOptionFlag);
  241.  
  242.     iMenu->AddItem( kAutoloadFlag, "Autoload images", true, true);
  243.     fAutoloadItem= (DView*) gViewCentral->GetView(kAutoloadFlag);
  244.     iMenu->AddItem( kEditGopherMap, "Edit view handlers...",false, true);
  245.     iMenu->AddItem( kOtherPrefs,     "Other prefs...",false, true);
  246. #endif
  247. #endif
  248.     iMenu->AddItem( kMailSetup,     "Mail setup...",false, true);
  249.  
  250.     aMenu= NULL;
  251.     this->SetUpMenu(DApplication::cWindowMenu, aMenu);
  252. }
  253.  
  254.  
  255.  
  256.  
  257.  
  258. class    DBugMailDialog : public DSendMailDialog
  259. {
  260. public:
  261.     DBugMailDialog(long id, DTaskMaster* itsSuperior,
  262.         short width = -5, short height = -5, short left = -50, short top = -20, char* title = NULL):
  263.         DSendMailDialog(id, itsSuperior, width, height, left, top, title)
  264.         {}
  265.  
  266.     virtual DView* InstallTo(DView* super, char* toStr)  //override
  267.     {
  268.         return DSendMailDialog::InstallTo(super, DSeqPup::kBugmailAddress);
  269.     }
  270. };
  271.  
  272.  
  273.  
  274. #if UseGopher
  275. class DLocalDialog : public DWindow
  276. {
  277. public:
  278.     enum { kSetDefault = 13345 };
  279.     DEditText* fQuery;
  280.     DLocalDialog();            
  281.     char* Result();
  282.     void OkayAction();
  283. };
  284.  
  285.  
  286. DLocalDialog::DLocalDialog() :
  287.     DWindow( 0, gApplication, fixed, -10, -10, -50, -20, "Local Gopher", kDontFreeOnClose)
  288. {
  289.         new DPrompt(0, this, "Open local folder?", 0, 0, Nlm_systemFont);             
  290.         this->NextSubviewBelowLeft();
  291.         fQuery= new DEditText(0, this, gLocalGopherRoot, 28); 
  292.         this->SetEditText(fQuery);
  293.         this->NextSubviewBelowLeft();
  294.         (void) new DCheckBox(kSetDefault,this,"Make this default local services folder");
  295.         this->AddOkayCancelButtons();
  296. }
  297.             
  298. void DLocalDialog::OkayAction() 
  299.     DWindow::OkayAction();
  300.     DCheckBox* ck = (DCheckBox*) this->FindSubview(kSetDefault);
  301.     if (ck && ck->GetStatus()) {
  302.         char* newroot= fQuery->GetText(); // this dups text
  303.         if (newroot) {
  304.             MemFree(gLocalGopherRoot);
  305.             gLocalGopherRoot= newroot;
  306.             }
  307.         }
  308. }
  309.  
  310. char* DLocalDialog::Result()
  311. {
  312.     if (fOkay) return fQuery->GetText();
  313.     else return NULL;
  314. }
  315. #endif
  316.  
  317.  
  318. void DSeqPup::OpenLocalGopher()
  319. {
  320. #if UseGopher
  321.     DLocalDialog* win= new DLocalDialog();
  322.     if ( win->PoseModally() ) {
  323.         char* localpath= win->Result();
  324.       DGopher* localgo= DGopherList::LocalGopher( localpath);
  325.         MemFree( localpath);
  326.       DGopherListDoc::ProcessGopher( localgo, 0);
  327.       }
  328.     delete win;  
  329. #endif
  330. }
  331.         
  332.  
  333.  
  334. void DSeqPup::OpenDocument(DFile* aFile)
  335. {
  336.     if (!aFile || !aFile->Exists()) return;
  337.     gCursor->watch();
  338.     if (DSeqDoc::IsSeqFile(aFile)) {
  339.         if (fAppendSeq) {
  340.             DSeqDoc* sdoc= (DSeqDoc*) gWindowManager->CurrentWindow();
  341.             if (sdoc && sdoc->Id() == DSeqDoc::kSeqdoc) 
  342.                 sdoc->Open(aFile);   
  343.             else
  344.                 fAppendSeq= false;
  345.             }
  346.         if (!fAppendSeq) {
  347.             DSeqDoc* sdoc= new DSeqDoc(DSeqDoc::kSeqdoc, NULL, NULL);
  348.             sdoc->Open(aFile);   
  349.             }
  350.         }
  351.         
  352.     else {
  353.         aFile->Close();
  354. #if UseGopher
  355.       DGopher* localgo= DGopherList::LocalGopher( aFile);
  356.       DGopherListDoc::ProcessGopher( localgo, 0);
  357. #else
  358.         DRichTextDoc* doc= new DRichTextDoc( 0, true, gTextFont);
  359.         doc->Open( aFile);
  360. #endif
  361.         }
  362.     gCursor->arrow();
  363. }
  364.  
  365.  
  366.  
  367. DWindow* DSeqPup::DoMakeDocument(short itsCommandNumber, DFile* aFile)
  368. {
  369.     DWindow* theDoc= NULL;
  370.     
  371.      switch (itsCommandNumber) {
  372. #if 0
  373.         case cOpenNAColors:
  374.         case cOpenAAColors: {
  375.             DColorPrefDocument* aDoc= new DColorPrefDocument();
  376.             if (itsCommandNumber == cOpenAAColors)
  377.                 aDoc->IColorPrefDocument( itsFile, kAmino);
  378.             else 
  379.                 aDoc->IColorPrefDocument( itsFile, kDNA);
  380.             return aDoc;
  381.             }
  382.  
  383.         case cOpenTree: {
  384.             DTreeDoc* aDoc= new DTreeDoc();
  385.             aDoc->ITreePrintDocument(kPrintClipType, NULL, NIL, itsFile);
  386.             return aDoc;
  387.             }
  388.         
  389.         // also handle gopher documents ... some gopher method should do this
  390.         
  391.         default:  { //== cNewProj/cOpenProj, cNew/cOpen
  392.             DAlnDoc* aDoc= new DAlnDoc();
  393.             aDoc->IAlnDoc( itsFile);
  394.             return aDoc;
  395.             }
  396. #endif
  397.         }
  398.         
  399.     return theDoc;
  400. }
  401.  
  402.  
  403.  
  404.  
  405.  
  406.         
  407. Boolean DSeqPup::IsInternetMenu(DTaskMaster* action) 
  408. {
  409.     DWindow* win;
  410.     DSeqDoc* sdoc = (DSeqDoc*) gWindowManager->CurrentWindow();
  411.  
  412.     switch(action->Id()) {
  413.  
  414.         case kCodonPref: 
  415.             DCodons::TableChoice();
  416.             return true;
  417.  
  418.         case kColorPref: 
  419.             DBaseColors::TableChoice();
  420.             return true;
  421.  
  422.         case kStylePref: 
  423.             DStyleTable::TableChoice();
  424.             return true;
  425.             
  426.         case kREnzymePref: 
  427.             DREMap::TableChoice();
  428.             return true;
  429.             
  430.         case kSaveWinPrefs: 
  431.             if (sdoc && sdoc->Id() == DSeqDoc::kSeqdoc) {
  432.                 sdoc->MakeGlobalsCurrent();
  433.                 DSeqDoc::SaveGlobals();
  434.                 fWinPrefsNotSaved= false;
  435.                 }
  436.             return true;
  437.  
  438.         case kSeqDocPrefs: 
  439.             SeqDocPrefs(kSeqDocPrefDialog);
  440.             return true;
  441.     
  442.         case kSeqPrintPrefs: 
  443.             SeqPrintPrefs(kSeqPrintPrefDialog);
  444.             return true;
  445.  
  446. #if UseGopher
  447.         case kViewPrefs: 
  448.             if (!gGoviewPrefs) {
  449.                 gGoviewPrefs = new DGoviewPrefs();
  450.                 gGoviewPrefs->Initialize();
  451.                 }
  452.             if (gGoviewPrefs && gGoviewPrefs->PoseModally()) ;
  453.             //delete gGoviewPrefs; // leave the window hidden but alive for later use
  454.             return true;
  455.             
  456.         case kOtherPrefs:
  457.             if (!gGoOtherPrefs) {
  458.                 gGoOtherPrefs = new DGoOtherPrefs();
  459.                 gGoOtherPrefs->Initialize();
  460.                 }
  461.             if (gGoOtherPrefs && gGoOtherPrefs->PoseModally()) ;
  462.             //delete gGoOtherPrefs; // leave the window hidden but alive for later use
  463.             return true;
  464.  
  465.         case  kFetchOptionFlag:
  466.             if (fFetchOptionMenuItem) DGopherListDoc::gOptionIsOn= fFetchOptionMenuItem->GetStatus();
  467.             else DGopherListDoc::gOptionIsOn = !DGopherListDoc::gOptionIsOn; // or read menu state
  468.             return true;
  469.  
  470.         case  kAutoloadFlag:
  471.             if (fAutoloadItem) DGoLinkedTextDoc::gAutoloadInlines= fAutoloadItem->GetStatus();
  472.             else DGoLinkedTextDoc::gAutoloadInlines = !DGoLinkedTextDoc::gAutoloadInlines; // or read menu state
  473.             return true;
  474.  
  475.         case  kExtractGodoc:
  476.             {
  477.             win= gWindowManager->CurrentWindow();
  478.             if (win && win->Id() == DGoLinkedTextDoc::kGoLitextdoc) {
  479.                 DGoLinkedTextDoc* ndoc= (DGoLinkedTextDoc *) win;
  480.                 switch (action->Id()) {
  481.                     case kExtractGodoc    : ndoc->ExtractGopherDoc(); break;
  482.                     }
  483.                 }
  484.             return true;
  485.             }
  486.  
  487.  
  488.         case  kLockWindow:
  489.             win= gWindowManager->CurrentWindow();
  490.             if (win && fLockWinMenuItem) {
  491.                 if (win->Id() == DGopherListDoc::kGoListdoc)
  492.                      ((DGopherListDoc *) win)->PinWindow( fLockWinMenuItem->GetStatus());
  493.                 else if (win->Id() == DGopherTextDoc::kGoTextdoc   
  494.                             || win->Id() == DGoLinkedTextDoc::kGoLitextdoc)  
  495.                     ((DGopherTextDoc *) win)->PinWindow( fLockWinMenuItem->GetStatus());
  496.                 }         
  497.             return true;
  498. #endif
  499.  
  500. #if UseGopher
  501.         case     kGetInfo:
  502.         case  kFetchLink:
  503.         case  kMailAdmin:
  504.         case    kFindServer:
  505.         case    kNewServer:
  506.         case    kNewLink:
  507.         case  kEditLink:
  508.             {
  509.             win= gWindowManager->CurrentWindow();
  510.             if (win && win->Id() == DGopherListDoc::kGoListdoc) {
  511.                 DGopher* go;
  512.                 short iview;
  513.                 DGopherListDoc* gdoc= (DGopherListDoc *) win;
  514.                 switch (action->Id()) {
  515.  
  516.                     case kFindServer:    gdoc->TopOfGopherHole(); break;
  517.                     case kNewServer    : gdoc->InsertNewGopher( false); break;
  518.                     case kNewLink        : gdoc->InsertNewGopher( true); break;
  519.                     case kEditLink    : gdoc->EditOldGopher(); break;
  520.                     case kGetInfo:
  521.                         iview= DGopher::kGetItemInfo;
  522.                             // fall thru to kFetchLink
  523.                     case kFetchLink:
  524.                         go= gdoc->fGoview->SelectedGopher();
  525.                         if (go) gdoc->ProcessGopher(go, iview);
  526.                         break;
  527. #if 0                    
  528.                     case kMailAdmin    :
  529.                         go= gdoc->fGoview->SelectedGopher();
  530.                         if (go && go->fAdminEmail) {
  531.                             win= new DAdminMailDialog(0, this, go);
  532.                             win->Open();
  533.                             }
  534.                         break;
  535. #endif
  536.                     }
  537.                 }
  538.             return true;
  539.             }
  540. #endif
  541.  
  542.          case    kMailSetup:
  543.             {
  544.             win= new DMailSetupDialog(0, this, -10, -10, -20, -20, "Mail Setup");
  545.             win->Open();
  546.             return true;
  547.             }
  548.         case     kSendMail: 
  549.             {
  550.             win= new DSendMailDialog(0, this, -10, -10, -20, -20, "Send Mail");
  551.             win->Open();
  552.             return true;
  553.             }
  554.         case  kBugMail:
  555.             {
  556.             win= new DBugMailDialog(0, this, -10, -10, -20, -20, "Comment about this App");
  557.             win->Open();
  558.             return true;
  559.             }
  560.             
  561.         default:    
  562.             if (sdoc && sdoc->Id() == DSeqDoc::kSeqdoc) 
  563.                 return sdoc->IsMyAction(action);
  564.             else return false;
  565.         }
  566. }
  567.  
  568.  
  569. Boolean DSeqPup::IsMyAction(DTaskMaster* action) 
  570. {
  571.     enum doctype { nodoc, anydoc, godoc, seq1doc, alndoc };
  572.     doctype    thedoc = nodoc;
  573.     Boolean    done= false;
  574.     
  575.     DWindow* win     = gWindowManager->CurrentWindow();
  576.     DSeqDoc* sdoc = (DSeqDoc*) win;
  577.     DSeqedWindow* s1doc= (DSeqedWindow*) win;
  578. #if UseGopher
  579.     DGopherListDoc* gdoc = (DGopherListDoc*) win;
  580. #endif
  581.     if (win) {
  582.         if (win->Id() == DSeqDoc::kSeqdoc) thedoc = alndoc;
  583.         else if (win->Id() == DSeqedWindow::kId) thedoc = seq1doc;
  584. #if UseGopher
  585.         else if (win->Id() == DGopherListDoc::kGoListdoc) thedoc = godoc;
  586. #endif
  587.         else thedoc= anydoc;
  588.         }
  589.         
  590.     short    menuitem = action->Id();
  591.           
  592.     if (action->fSuperior)  
  593.         switch (action->fSuperior->Id()) {
  594.  
  595.             case kOpenMenu : 
  596.             case cFileMenu : 
  597.               switch (menuitem) {
  598.               
  599.                 case kNewServer:
  600.                     return IsInternetMenu(action);
  601.                     
  602.                 case DSeqDoc::cSaveSel:
  603.                     goto caseSeqDoc;
  604.                     
  605.                 case DApplication::kNew:
  606.                     DSeqDoc::NewSeqDoc();
  607.                     return true;
  608.                     
  609.                 case kOpenText:
  610.                     DApplication::DoMenuTask(DApplication::kOpen, NULL);
  611.                     return true;
  612.                     
  613.                 case kOpenTree:
  614.                     return true;
  615.                     
  616.                 case kOpenAppendSeq:
  617.                     fAppendSeq= true;
  618.                 case kOpenSeq:
  619.                 case DApplication::kOpen:
  620.                     DSeqDoc::fgTestSeqFile= true; // ???
  621.                     DApplication::DoMenuTask(DApplication::kOpen,NULL);
  622.                     DSeqDoc::fgTestSeqFile= false;
  623.                     fAppendSeq= false;
  624.                     return true;
  625. #if UseGopher
  626.                 case kOpenLocalGo:
  627.                     OpenLocalGopher();
  628.                     return true;
  629. #endif
  630.                  default: 
  631.                     return DApplication::IsMyAction(action);
  632.                 }
  633.                 break;
  634.         
  635.         
  636.             case DApplication::cEditMenu:
  637. #if 1
  638.                 if (thedoc == alndoc) done= sdoc->IsMyAction(action);
  639.                 else if (thedoc == seq1doc) done= s1doc->IsMyAction(action);
  640.                 else done= false;
  641.                 if (done) return true;
  642. #else
  643.                 if (menuitem == DSeqDoc::cFindORF) {
  644.                     if (thedoc == alndoc) return sdoc->IsMyAction(action);
  645.                     else if (thedoc == seq1doc) return s1doc->IsMyAction(action);
  646.                     }
  647. #endif
  648.                 break;
  649.                 
  650.             case kInternetMenu    :
  651.             case kPrefsMenu : 
  652. #if UseGopher
  653.                 if (menuitem == DGopherListDoc::kViewChoiceMenu) 
  654.                     goto caseViewChoiceMenu; 
  655.                 else
  656. #endif
  657.                   return IsInternetMenu(action);
  658.                 
  659. #if UseGopher
  660.             case DGopherListDoc::kViewKindMenu    : 
  661.                 if (thedoc == godoc) return gdoc->IsMyAction(action);
  662.                 else return false;
  663.                 
  664.             case DGopherListDoc::kViewChoiceMenu    : 
  665.             caseViewChoiceMenu:
  666.                 if (thedoc == godoc) return gdoc->IsMyAction(action);
  667.                 else return false;
  668. #endif
  669.             
  670.             case DSeqApps::kChildMenu :
  671.                 // ?? do we always need DSeqDoc window active for childmenus ??
  672.             case DSeqDoc::kSeqMenu    : 
  673.             case DSeqDoc::kViewKindMenu    : 
  674.             case DSeqDoc::kSeqMaskMenu    : 
  675.             caseSeqDoc:
  676.                 switch(menuitem) {
  677.                     case DSeqDoc::cNAcodes:    NucCodesPicture(); return true;
  678.                     case DSeqDoc::cAAcodes: AminoCodesPicture(); return true;
  679.                     }
  680.                 if (thedoc == alndoc) return sdoc->IsMyAction(action);
  681.                 else if (thedoc == seq1doc) return s1doc->IsMyAction(action);
  682.                 else return false;
  683.             }
  684.      
  685.      
  686.     switch(menuitem) {
  687.  
  688.         case DApplication::kNew:
  689.             DSeqDoc::NewSeqDoc();
  690.             return true;
  691.         default: 
  692.             return DApplication::IsMyAction(action);
  693.         }
  694. }
  695.  
  696.  
  697.  
  698. void DSeqPup::UpdateMenus(void)
  699. {
  700.     DApplication::UpdateMenus();
  701.     
  702.     //gViewCentral->EnableView(kSpecial1);
  703.     //gViewCentral->EnableView(kSpecial2);
  704. }
  705.  
  706.  
  707.